<template>
  <div id="login">
    <div class="bg"></div>
    <el-row class="main-container">
      <el-col :lg="6" :xs="16" :md="10" :span="10">
        <div class="top">
          <i class="iconfont icon-kaoshi"></i><span class="title">毕业生就业系统</span>
        </div>

        <el-form
          class="fromBasePosition"
          label-width="100px"
          style="max-width: 460px"
        >
          <div style="display: flex">
            <el-col :span="1"> <el-button type="text" @click="back()">返回</el-button></el-col>
            <el-col :span="23"><h2 style="text-align: center">注册账号</h2></el-col>
          </div>

          <el-divider content-position="center">注册信息</el-divider>


          <el-form-item label="用户名" >
            <el-input v-model="formRegister.username" placeholder="请输入用户名"/>
          </el-form-item>

          <el-form-item label="密码" >
            <el-input v-model="formRegister.password" type="password" placeholder="请输入密码" show-password/>
          </el-form-item>

          <el-form-item label="手机号" >
            <el-input v-model="formRegister.numPhone"  placeholder="请输入手机号" />
          </el-form-item>

          <el-form-item label="邮箱" >
            <el-input v-model="formRegister.email"  placeholder="请输入邮箱" />
          </el-form-item>

          <div style="display: flex;justify-content: center">
            <el-button type="primary" @click="toRegister()" style=" margin-bottom: 10px;width: 70%;">注册</el-button>
          </div>
        </el-form>

      </el-col>
    </el-row>
  </div>

</template>

<script>
export default {
  name: "register",
  data(){
    return{
      formRegister:{
        username:'',
        password:'',
        email:'',
        numPhone:'',
      }
    }
  },
  methods:{
    toRegister() {
      this.$axios({
        url:'/api/user/register',
        method:'post',
        data:{
          ...this.formRegister
        }
      }).then(res=>{
        let resData=res.data
        console.log(resData)
        //注册失败
        if (resData.code){
          this.$message({
            showClose: true,
            type: 'error',
            message: resData.message
          })
        }
        //注册成功
        if (!resData.code){
          this.$message({
            showClose: true,
            type: 'success',
            message: resData.message
          })
          this.$router.push({path:'/'})
        }
      })
    },
    back(){
      this.$router.push({path:'/'})
    }
  }
}
</script>

<style scoped>
.fromBasePosition{

  border: 1px solid #f6f6f6;
  padding: 35px 35px 15px 35px;
  background-color: #fff;
  border-radius: 15px;
  box-shadow: 0 0 25px #cac6c6;

}
.remind {
  border-radius: 4px;
  padding: 10px 20px;
  display: flex;
  position: fixed;
  right: 20px;
  bottom: 50%;
  flex-direction: column;
  color: #606266;
  background-color: #fff;
  border-left: 4px solid #409eff;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)
}
.container {
  margin-bottom: 32px;
}
.container .el-radio-group {
  margin: 30px 0px;
}
a:link {
  color:#8f6234;
  text-decoration:none;
}
#login {
  font-size: 14px;
  color: #000;
  background-color: #fff;
}
#login .bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  overflow-y: auto;
  height: 100%;
  background: url('../../assets/img/loginBg.png')center top / cover no-repeat;
  background-color: #b6bccdd1 !important;
}
#login .main-container {
  display: flex;
  justify-content: center;
  align-items: center;
}
#login .main-container .top {
  margin-top: 100px;
  font-size: 30px;
  color:#8f6234;
  display: flex;
  justify-content: center;
}
#login .top .icon-kaoshi {
  font-size: 80px;
}
#login .top .title {
  margin-top: 20px;
}
#login .bottom {
  display:flex;
  justify-content: center;
  background-color:#fff;
  border-radius: 5px;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
#login .bottom .title {
  text-align: center;
  font-size: 30px;
}
.bottom .container .title {
  margin: 30px 0px;;
}
.bottom .submit .row-login {
  width: 100%;
  background-color: #04468b;
  border-color: #04468b;
  margin: 20px 0px 10px 0px;
  padding: 15px 20px;
}
.bottom .submit {
  display: flex;
  justify-content: center;
}
.footer {
  margin-top: 50px;
  text-align: center;
}
.footer .msg1 {
  font-size: 18px;
  color: #fff;
  margin-bottom: 15px;
}
.footer .msg2 {
  font-size: 14px;
  color: #e3e3e3;
  margin-top: 70px;
}
.bottom .options {
  margin-bottom: 40px;
  color: #ff962a;
  display: flex;
  justify-content: space-between;
}
.bottom .options > a {
  color: #ff962a;
}
.bottom .options .register span:nth-child(1) {
  color: #8C8C8C;
}
</style>
